/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo;
import java.io.*;
/**
 *
 * @author user
 */
public class Serializacion {
    public static void main(String[] args) {

        Agenda a1 = new Agenda("Ana1", "Martínez1", "Fernández1");
        Agenda a2 = new Agenda("Ernesto", "García", "Pérez");

        try {
            FileOutputStream fs = new FileOutputStream("agenda1.ser");
            ObjectOutputStream os = new ObjectOutputStream(fs);

            os.writeObject(a1);
            os.writeObject(a2);

            os.close();

        } catch (FileNotFoundException e) {

            e.printStackTrace();

        } catch (IOException e) {

            e.printStackTrace();

        }

        System.out.println("Los Objetos se han serializado correctamente.");

    }
}
